﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpBot
{
    public static class Lolisuite
    {
        static readonly string botName = "Lolisuite";

        public static void init()
        {
            Console.Title = "C# " + botName + " is up and running!";

            Console.Write("[");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write(botName);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("] ");
            Console.WriteLine();
        suiteRestart:
            Console.Write("Command: ");
            Console.ForegroundColor = ConsoleColor.Magenta;
            string command = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Gray;

            string[] arguments = command.Split(' ');
            if (arguments.Length > 0)
            {
                if (arguments[0] == "help")
                    help();
                if (arguments[0] == "!loli")
                    Loli(DateTime.Now.DayOfYear);
                if (arguments[0] == "!imouto")
                    Imouto(DateTime.Now.DayOfYear);
                if (arguments[0] == "!pantsu")
                    Pantsu(DateTime.Now.DayOfYear);
                if (arguments[0] == "exit")
                    Environment.Exit(0);
            }
            goto suiteRestart;
        }

        private static void help()
        {
            Console.WriteLine("--- " + botName + " Help ---");
            Console.WriteLine(" !loli    - gives you some lolis.");
            Console.WriteLine(" !shota   - gives you some shotas.");
            Console.WriteLine(" !pantsu  - gives you some pantsus.");
            Console.WriteLine(" !onee    - gives you some kawaii onee-sans.");
            Console.WriteLine(" !imouto  - gives you some young little sisters.");
            Console.WriteLine(" !loli++  - gives you some lolis, shotas, pantsus, onee-sans, little sisters,\r\n but can only be used once if you haven't used any other command.");
            Console.WriteLine(" !lolilot - requires input, will play a little lottery with your input lolis,\r\n you can earn big prices!");
            Console.WriteLine(" exit     - quite obvious, no?");
        }

        private static void Loli(int dayofyear)
        {
            try
            {
                Random rnd = new Random();
                int today = dayofyear;
                int last = Convert.ToInt32(new INIFile(@Environment.CurrentDirectory + @"\Settings.ini").Read("Lolisuite", "LastTimeUsedLoliCommand"));
                int lolis = Convert.ToInt32(new INIFile(@Environment.CurrentDirectory + @"\Settings.ini").Read("Lolisuite", "Lolis"));
                int newLolis = 0;
                int newTotal = 0;

                if (today != last)
                {
                    if (last > today)
                    {
                        Console.Write("[");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write(botName);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.Write("] How dare you change the date..");
                        Console.WriteLine();
                    }
                    else
                    {
                        newLolis += rnd.Next(1, 6);
                        newTotal = lolis + newLolis;

                        Console.Write("[");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write(botName);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.Write("] gave you ");
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.Write(newLolis);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        if (newLolis == 1)
                            Console.Write(" Loli, ");
                        else
                            Console.Write(" Lolis, ");
                        Console.Write("you got a total of ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write(newTotal);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.Write(" Lolis.");
                        Console.WriteLine();

                        new INIFile(@Environment.CurrentDirectory + @"\Settings.ini").Write("Lolisuite", "LasttimeUsedLoliCommand", Convert.ToString(today));
                        new INIFile(@Environment.CurrentDirectory + @"\Settings.ini").Write("Lolisuite", "Lolis", Convert.ToString(newTotal));
                    }
                }
                else
                {
                    Console.Write("[");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write(botName);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("] ");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("You already got lolis today!");
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.WriteLine();
                }
            }
            catch
            {
                Console.Write("[");
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write(botName);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("] ");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("Can't convert String to Integer.");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine();
            }
        }
        private static void Shota(int dayofyear)
        {
        }
        private static void Pantsu(int dayofyear)
        {
            try
            {
                Random rnd = new Random();
                int today = dayofyear;
                int last = Convert.ToInt32(new INIFile(@Environment.CurrentDirectory + @"\Settings.ini").Read("Lolisuite", "LastTimeUsedPantsuCommand"));
                int pantsus = Convert.ToInt32(new INIFile(@Environment.CurrentDirectory + @"\Settings.ini").Read("Lolisuite", "Pantsus"));
                int newPantsus = 0;
                int newTotal = 0;

                if (today != last)
                {
                    if (last > today)
                    {
                        Console.Write("[");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write(botName);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.Write("] How dare you change the date..");
                        Console.WriteLine();
                    }
                    else
                    {
                        newPantsus += rnd.Next(1, 6);
                        newTotal = pantsus + newPantsus;

                        Console.Write("[");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write(botName);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.Write("] gave you ");
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.Write(newPantsus);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        if (pantsus == 1)
                            Console.Write(" Pantsu, ");
                        else
                            Console.Write(" Pantsus, ");
                        Console.Write("you got a total of ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write(newTotal);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.Write(" Pantsus.");
                        Console.WriteLine();

                        new INIFile(@Environment.CurrentDirectory + @"\Settings.ini").Write("Lolisuite", "LasttimeUsedPantsuCommand", Convert.ToString(today));
                        new INIFile(@Environment.CurrentDirectory + @"\Settings.ini").Write("Lolisuite", "Pantsus", Convert.ToString(newTotal));
                    }
                }
                else
                {
                    Console.Write("[");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write(botName);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("] ");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("You already got pantsus today!");
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.WriteLine();
                }
            }
            catch
            {
                Console.Write("[");
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write(botName);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("] ");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("Can't convert String to Integer.");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine();
            }
        }
        private static void Onee(int dayofyear)
        {
        }
        private static void Imouto(int dayofyear)
        {
            try
            {
                Random rnd = new Random();
                int today = dayofyear;
                int last = Convert.ToInt32(new INIFile(@Environment.CurrentDirectory + @"\Settings.ini").Read("Lolisuite", "LastTimeUsedImoutoCommand"));
                int imoutos = Convert.ToInt32(new INIFile(@Environment.CurrentDirectory + @"\Settings.ini").Read("Lolisuite", "Imoutos"));
                int newImoutos = 0;
                int newTotal = 0;

                if (today != last)
                {
                    if (last > today)
                    {
                        Console.Write("[");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write(botName);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.Write("] How dare you change the date..");
                        Console.WriteLine();
                    }
                    else
                    {
                        newImoutos += rnd.Next(1, 6);
                        newTotal = imoutos + newImoutos;

                        Console.Write("[");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write(botName);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.Write("] gave you ");
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.Write(newImoutos);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        if (imoutos == 1)
                            Console.Write(" Imouto, ");
                        else
                            Console.Write(" Imoutos, ");
                        Console.Write("you got a total of ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write(newTotal);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.Write(" Imoutos.");
                        Console.WriteLine();

                        new INIFile(@Environment.CurrentDirectory + @"\Settings.ini").Write("Lolisuite", "LasttimeUsedImoutoCommand", Convert.ToString(today));
                        new INIFile(@Environment.CurrentDirectory + @"\Settings.ini").Write("Lolisuite", "Imoutos", Convert.ToString(newTotal));
                    }
                }
                else
                {
                    Console.Write("[");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write(botName);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("] ");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("You already got imoutos today!");
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.WriteLine();
                }
            }
            catch
            {
                Console.Write("[");
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write(botName);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("] ");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("Can't convert String to Integer.");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine();
            }
        }
        private static void LoliPP(int doy1, int doy2, int doy3, int doy4, int doy5) //Doy= Day Of Year, this is just for every command.
        {
        }
        private static void Loliottery(int dayofyear, int num)
        {
        }

        private static void AniAir(string[] args)
        {

        }
        private static bool checkIfChangedINI(string command)
        {
            int yesterday = DateTime.Now.DayOfYear - 1;
            if ((new INIFile(@Environment.CurrentDirectory + @"\Settings.ini")).Read("", "") == "")
            {

                return true;
            }
            return false;
        }
    }
}
